package com.exam.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.exam.pojo.Question;
import com.exam.mapper.QuestionMapper;
import com.exam.service.QuestionService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.exam.vo.ExamPaperVO;
import com.exam.vo.examEnum.QuestionTypeEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author XiaoKai
 * @since 2021-07-31
 */
@Service
public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> implements QuestionService {
    @Autowired
    private QuestionMapper questionMapper;
    @Override
    public ExamPaperVO getExamPaper(Integer paperId) {
        ExamPaperVO examPaperVO = new ExamPaperVO();
        Map<String, Object> map = new HashMap<>();
        //枚举类
        for (QuestionTypeEnum e : QuestionTypeEnum.values()){
            List<Question> questions = questionMapper.listQuestion(paperId, e.getQuestionType());
            System.out.println(questions);
            map.put(e.getName(),questions);
        }
        examPaperVO.setChoices(map);
        System.out.println("11111111111111111"+map);
        return examPaperVO;
    }
}
